<?php
$dis_id=2;
include("../../inc/conn.inc");
include("../islogin.php");
if($_POST[tj_act]){
mysql_query("insert into web_link (member_id,web_name,web_url) values ('".$_COOKIE['user_id']."','$_POST[web_name]','$_POST[web_url]')");

echo "<script>alert('添加成功');location='link.php';</script>";
}

if($_POST['xg_act']){
mysql_query("update web_link set web_name='$_POST[web_name]',web_url='$_POST[web_url]' where id='".$_POST['iid']."' and member_id='".$_COOKIE['user_id']."'");

echo "<script>alert('修改成功');location='link.php';</script>";
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>会员中心-三帝贸易网</title>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
</head>
<script type="text/javascript" src="../js/left.js"></script>
<body>
<div id="mian">
<?php include("../inc/top.php");?>
<div class="top1"><span>您当前位置：<a href="../index.php" class="dh">会员助手</a> &gt;&gt; 企业网站配置 &gt;&gt; 添加友情链接</span></div>
<div class="left">
<?php include("../inc/left.php");?>
</div>
<div class="right">
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
   <TR>
     <TD height="40" bgcolor="#EFF6FF" style="font-size:18px;font-weight:bold;padding-left:8px;">添加友情链接</TD>
   </TR>
</TABLE>
<br>
<?php if($_GET[tj]){?>
<TABLE width="100%" border="0" cellpadding="0" cellSpacing="1" bgcolor="#C1DCF5">
        <TBODY>
        <form method="post" action="" name="form1" onSubmit="return checkform()">
          <TR>
            <td width="24%" height="25" align="right" bgcolor="#EFF6FF">网站名称<font color="red">*</font></td>
            <TD width="76%" bgcolor="#F9F9F9" style="padding-left:4px;"><input id="web_name" name="web_name" type="text" size="20" maxlength="20"></TD>
          </TR>
          <TR>
            <td width="24%" height="25" align="right" bgcolor="#EFF6FF">网站地址<font color="red">*</font></td>
            <TD width="76%" bgcolor="#F9F9F9" style="padding-left:4px;"><input name="web_url" type="text" id="web_url" value="http://" size="35" maxlength="50"></TD>
          </TR>          
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">&nbsp;</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input type="submit" value="提交">
            <input type="hidden" name="tj_act" value="ok"></TD>
          </TR>
 </form>                
</TABLE>
<?php }
if($_GET[xg_id]){
$rs=@mysql_query("select id,web_name,web_url from web_link where id='".$_GET['xg_id']."'");
$row=@mysql_fetch_array($rs);
?>
<TABLE width="100%" border="0" cellpadding="0" cellSpacing="1" bgcolor="#C1DCF5">
        <TBODY>
        <form method="post" action="" name="form1" onSubmit="return checkform()">
          <TR>
            <td width="24%" height="25" align="right" bgcolor="#EFF6FF">网站名称<font color="red">*</font></td>
            <TD width="76%" bgcolor="#F9F9F9" style="padding-left:4px;"><input id="web_name" name="web_name" type="text" value="<?=$row[web_name]?>" size="20" maxlength="20"></TD>
          </TR>
          <TR>
            <td width="24%" height="25" align="right" bgcolor="#EFF6FF">网站地址<font color="red">*</font></td>
            <TD width="76%" bgcolor="#F9F9F9" style="padding-left:4px;"><input name="web_url" type="text" id="web_url" value="<?=$row[web_url]?>" size="35" maxlength="50"></TD>
          </TR>          
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">&nbsp;</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;">
			<input type="hidden" name="iid" value="<?=$row['id']?>">
			<input type="submit" value="提交">
            <input type="hidden" name="xg_act" value="ok"></TD>
          </TR>
 </form>                
</TABLE>
<?php }?>
</div>
<div class="onl"></div>
<?php include("../inc/foot.php");?>
</div>
</body>
</html>

<script language="javascript">
function $(id){
return document.getElementById(id);
}
function checkform(){
if($("web_name").value==""){
alert("网站名称不能为空");
$("web_name").focus();
return false;
}
if($("web_url").value==""){
alert("链接地址不能为空");
$("web_url").focus();
return false;
}
if($("web_url").value=="http://"){
alert("请输入您的链接地址");
$("web_url").focus();
return false;
}
}
</script>